Content
- R Markdown documents include the markdown text itself, as well as output from code chunks
- Code chunks can output data, graphs, tables, and images
- You can also reference variables from code chunks in markdown text
---
title: "Why R Markdown Is the Best"
author: "Me"
output: html_document
---
Plain text-formatting allows for conversion to different document types
1. People
1. Order
1. Our
1. Patties
```{r example}
## Load packages ##
# Package list
pkg_list <- c(tidyverse", "ggplot2", "kableExtra", "patchwork")
# Load packages
pacman::p_load(pkg_list, character.only = TRUE)
```
To test your code chunks, you can:
knitrenderknit button or command/CTRL + shift + Krmarkdown::render(file, output_format)pagedown::chrome_print(file)html_documentpdf_documentword_documentioslides_presentation and slidy_presentation for HTMLbeamer_presentation for PDFpowerpoint_presentationrevealjsvitaeposterdownpapajarticlesprettydocbookdown---
output:
pdf_document:
template: plos_latex_template.tex
---
Go to the Styles Pane in Word, format, and “Update to Match Selection”
---
output:
word_document:
reference_docx: template.docx
---
# Pull species column from iris and get unique values in column
species <- iris %>% pull(Species) %>% unique()
# Get number of unique species
species_count <- length(species)`r species_count``r species`: setosa, versicolor, virginica---
title: |
<center> A very impressive title: </center>
<center> An equally impressive subtitle </center>
---
installed.packages()# Define new variable y
y <- 100
# When I run this chunk, I get the expected output (150),
# but it fails when I try to knit the document
# I've set eval=FALSE for this chunk, so it doesn't try to run and prevent my document from knitting
print(x + y)package::function notationrmarkdown) in your library with update.packages(path)install.packages("package")updateR packagerm(ls = list()) in the console?package or ??packagescholar package for automatically downloading citations from Google Scholardevtools package for installing packages/plug-ins from GitHub (e.g., papaja)